<!DOCTYPE html>
<html>

  <head>
    <meta charset="utf-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1">
	<meta http-equiv="Cache-Control" content="no-siteapp" />

    <title>The tessellate polygon drawing algorithm</title>
    <meta name="description" content="The algorithm is based on libtess2 here and we optimizated some implementation and fixed some bugs.The differents between our algorithm and libtess2’s algori...">

    
    <meta name="keywords" content="gbox,c,tessellate,polygon,algorithm,drawing,monotone,triangulation,tboox" /> 

    <!-- qq oauth -->
    <meta property="qc:admins" content="5211601217706727767255" />

    <!--icon -->
    <link rel="shortcut icon" href="/favicon.ico" type="image/x-icon">
    <link rel="icon" sizes="192x192" href="/static/img/nice-highres.png" />
	<link rel="apple-touch-icon-precomposed" href="/static/img/apple-touch-icon-57x57-precomposed.png" />
	<link rel="apple-touch-icon-precomposed" sizes="72x72" href="/static/img/apple-touch-icon-72x72-precomposed.png" />
	<link rel="apple-touch-icon-precomposed" sizes="114x114" href="/static/img/apple-touch-icon-114x114-precomposed.png" />
	<link rel="apple-touch-icon-precomposed" sizes="144x144" href="/static/img/apple-touch-icon-144x144-precomposed.png" />
	<link rel="apple-touch-icon-precomposed" sizes="180x180" href="/static/img/retinahd_icon.png" />
	<meta name="msapplication-TileImage" content="/static/img/retinahd_icon.png" />
	
    <link rel="stylesheet" href=" /css/fontawesome/css/font-awesome.min.css ">
    <link rel="stylesheet" href=" /css/main.css ">
    <link rel="canonical" href="https://tboox.org/2016/07/21/tessellate-polygon-algorithm/">
    <link rel="alternate" type="application/rss+xml" title="TBOOX Open Source Project" href="https://tboox.org/feed.xml ">
    <link rel="alternate" hreflang="en" href="https://tboox.org/" />
    <link rel="alternate" hreflang="zh-Hans" href="https://tboox.org/cn/" />




    <script type="text/javascript">
    function isPC(){    
        var userAgentInfo = navigator.userAgent;  
        var Agents = new Array("Android", "iPhone", "SymbianOS", "Windows Phone", "iPad", "iPod");    
        var flag = true;    
        for (var v = 0; v < Agents.length; v++) {    
            if (userAgentInfo.indexOf(Agents[v]) > 0) { flag = false; break; }    
        }    
        return flag;    
    }
    </script>

<!-- baidu ads -->



    <!-- baidu ads -->

</head>


  <body>

    <header id="top">
    <div class="wrapper">
        <a href="/" class="brand">TBOOX</a>
        <button id="headerMenu" class="menu"><i class="fa fa-bars"></i></button>
        <nav id="headerNav">
            <ul>
                <li>
                    
                    <a href="/cn?lang=0">
                    
                        <i class="fa fa-home"></i>中文
                    </a>
                </li>

                
                    
                     
                    
                
                    
                     
                     
                    <li>

                        
                            
                            <a href="/project/">
                            
                        
                            <i class="fa fa-bookmark"></i>Projects
                        </a>
                    </li>
                    
                    
                    
                
                    
                     
                    
                
                    
                     
                     
                    <li>

                        
                            
                            <a href="/archive/">
                            
                        
                            <i class="fa fa-archive"></i>Archives
                        </a>
                    </li>
                    
                    
                    
                
                    
                     
                    
                
                    
                     
                     
                    <li>

                        
                            
                            <a href="/category/">
                            
                        
                            <i class="fa fa-th-list"></i>Categories
                        </a>
                    </li>
                    
                    
                    
                
                    
                     
                    
                
                    
                     
                     
                    <li>

                        
                            
                            <a href="/tag/">
                            
                        
                            <i class="fa fa-tags"></i>Tags
                        </a>
                    </li>
                    
                    
                    
                
                    
                
                    
                     
                    
                
                    
                     
                     
                    <li>

                        
                            
                            <a href="/docs/">
                            
                        
                            <i class="fa fa-book"></i>Documents
                        </a>
                    </li>
                    
                    
                    
                
                    
                     
                    
                
                    
                     
                     
                    <li>

                        
                            
                            <a href="https://xmake.io/#/about/contact" target="_blank" >
                            
                        
                            <i class="fa fa-forumbee"></i>Community
                        </a>
                    </li>
                    
                    
                    
                
                    
                     
                    
                
                    
                     
                     
                    <li>

                        
                            
                            <a href="/donation/">
                            
                        
                            <i class="fa fa-heart"></i>Donate
                        </a>
                    </li>
                    
                    
                    
                
                    
                     
                    
                
                    
                     
                     
                    <li>

                        
                            
                            <a href="/about/">
                            
                        
                            <i class="fa fa-user"></i>About
                        </a>
                    </li>
                    
                    
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                     
                     
                    
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                
            </ul>
        </nav>
    </div>
</header>



        <div class="page clearfix" post>
    <div class="left">
        <h1>The tessellate polygon drawing algorithm</h1>
        <div class="label">

            <div class="label-card">
                <i class="fa fa-calendar"></i>2016-07-21
            </div>

            <div class="label-card">
                
            </div>

            <div class="label-card">
                
            </div>

            <div class="label-card">
            


<!-- <span class="point">•</span> -->
<span class="categories">
  <i class="fa fa-th-list"></i>
  
    
        <a href="/category/#gbox" title="Category: gbox" rel="category">gbox</a>
    
  

  <!-- <span class="point">•</span> -->
</span>


            </div>

            <div class="label-card">
            
<!-- <span class="point">•</span> -->
<span class="pageTag">
  <i class="fa fa-tags"></i>
  
    
        <!--a href="/tag/#gbox" title="Tag: gbox" rel="tag">gbox</a-->
        <a href="/tag/#gbox" title="Tag: gbox" rel="tag">gbox</a>&nbsp;
    
        <!--a href="/tag/#c" title="Tag: c" rel="tag">c</a-->
        <a href="/tag/#c" title="Tag: c" rel="tag">c</a>&nbsp;
    
        <!--a href="/tag/#tessellate" title="Tag: tessellate" rel="tag">tessellate</a-->
        <a href="/tag/#tessellate" title="Tag: tessellate" rel="tag">tessellate</a>&nbsp;
    
        <!--a href="/tag/#polygon" title="Tag: polygon" rel="tag">polygon</a-->
        <a href="/tag/#polygon" title="Tag: polygon" rel="tag">polygon</a>&nbsp;
    
        <!--a href="/tag/#algorithm" title="Tag: algorithm" rel="tag">algorithm</a-->
        <a href="/tag/#algorithm" title="Tag: algorithm" rel="tag">algorithm</a>&nbsp;
    
        <!--a href="/tag/#drawing" title="Tag: drawing" rel="tag">drawing</a-->
        <a href="/tag/#drawing" title="Tag: drawing" rel="tag">drawing</a>&nbsp;
    
        <!--a href="/tag/#monotone" title="Tag: monotone" rel="tag">monotone</a-->
        <a href="/tag/#monotone" title="Tag: monotone" rel="tag">monotone</a>&nbsp;
    
        <!--a href="/tag/#triangulation" title="Tag: triangulation" rel="tag">triangulation</a-->
        <a href="/tag/#triangulation" title="Tag: triangulation" rel="tag">triangulation</a>
    
  

</span>

            </div>

        </div>
        <hr>
        <article itemscope itemtype="http://schema.org/BlogPosting">
        <p>The algorithm is based on libtess2 here and we optimizated some implementation and fixed some bugs.</p>

<p>The differents between our algorithm and libtess2’s algorithm:</p>

<ul>
  <li>We change the coordinate system and the sweep direction (sweep line by horizontal here).</li>
  <li>We need not project the vertices because our graphic engine is 2d,
so our algorithm will be faster.</li>
  <li>We processed more cases of the intersection with some numerical errors, 
so our algorithm will be more stable.</li>
  <li>We change the algorithm of comparing the active edge and make it more stable for numerical errors.</li>
  <li>We optimizate the algorithm of merging into the convex polygon from the triangulated mesh.</li>
  <li>We have not counted the vertices for each region, so it will be faster than libtess2.</li>
</ul>

<p>(you can see <a href="https://github.com/memononen/libtess2/blob/master/alg_outline.md">libtess2/alg_outline.md</a> if want to known more details of algorithm.)</p>

<p>There are four stages to the algorithm:</p>

<ol>
  <li>Build a mesh (DCEL, be similar to quad-edge) from polygon.</li>
  <li>Tessellate the mesh into the monotone regions if the polygon is concave.</li>
  <li>Triangulate the monotone regions.</li>
  <li>Merge the triangulated regions into the convex regions.</li>
</ol>

<p>There are seven stages to the tessellation algorithm:</p>

<ol>
  <li>Simplify the mesh and process some degenerate cases.</li>
  <li>Build a vertex event queue and sort it (uses the priority queue with min-heap).</li>
  <li>Build an active edge region list and sort it (uses the partial insertion sort).</li>
  <li>Sweep all events from the event queue using the Bentley-Ottman line-sweep algorithm and calculate the intersection and winding number.</li>
  <li>We need fix it if the intersection with numerical errors violate the mesh topology or active edge list ordering.</li>
  <li>Process some degenerate cases for the mesh faces which were generated when we fixed some cases.</li>
  <li>Get the monotone regions with the left face marked “inside”</li>
</ol>

<p>The triangulation test result:</p>

<p><img src="/static/img/gbox/test_triangulation1.png" alt="test_triangulation1" />
<img src="/static/img/gbox/test_triangulation2.png" alt="test_triangulation2" />
<img src="/static/img/gbox/test_triangulation3.png" alt="test_triangulation3" /></p>

<p>The drawing result with opengl(60 fps on my mac pro):</p>

<p><img src="/static/img/gbox/draw_tiger.png" alt="draw_tiger" /></p>

<p>Please refer to the source code <a href="https://github.com/waruqi/gbox/blob/master/src/gbox/utils/impl/tessellator/monotone.c">monotone.c</a> if you want to know more verbose monotone algorithm implementation.</p>

<p>And the tessellator interfaces usage from <a href="https://github.com/waruqi/gbox/blob/master/src/gbox/core/device/gl/render.c">gbox/gl/render.c</a>:</p>

<div class="language-c highlighter-rouge"><pre class="highlight"><code>    <span class="k">static</span> <span class="n">tb_void_t</span> <span class="nf">gb_gl_render_fill_convex</span><span class="p">(</span><span class="n">gb_point_ref_t</span> <span class="n">points</span><span class="p">,</span> <span class="n">tb_uint16_t</span> <span class="n">count</span><span class="p">,</span> <span class="n">tb_cpointer_t</span> <span class="n">priv</span><span class="p">)</span>
    <span class="p">{</span>
        <span class="c1">// check
</span>        <span class="n">tb_assert</span><span class="p">(</span><span class="n">priv</span> <span class="o">&amp;&amp;</span> <span class="n">points</span> <span class="o">&amp;&amp;</span> <span class="n">count</span><span class="p">);</span>

        <span class="c1">// apply it
</span>        <span class="n">gb_gl_render_apply_vertices</span><span class="p">((</span><span class="n">gb_gl_device_ref_t</span><span class="p">)</span><span class="n">priv</span><span class="p">,</span> <span class="n">points</span><span class="p">);</span>

<span class="cp">#ifndef GB_GL_TESSELLATOR_TEST_ENABLE
</span>        <span class="c1">// draw it
</span>        <span class="n">gb_glDrawArrays</span><span class="p">(</span><span class="n">GB_GL_TRIANGLE_FAN</span><span class="p">,</span> <span class="mi">0</span><span class="p">,</span> <span class="p">(</span><span class="n">gb_GLint_t</span><span class="p">)</span><span class="n">count</span><span class="p">);</span>
<span class="cp">#else
</span>        <span class="c1">// the device 
</span>        <span class="n">gb_gl_device_ref_t</span> <span class="n">device</span> <span class="o">=</span> <span class="p">(</span><span class="n">gb_gl_device_ref_t</span><span class="p">)</span><span class="n">priv</span><span class="p">;</span>

        <span class="c1">// make crc32
</span>        <span class="n">tb_uint32_t</span> <span class="n">crc32</span> <span class="o">=</span> <span class="mh">0xffffffff</span> <span class="o">^</span> <span class="n">tb_crc_encode</span><span class="p">(</span><span class="n">TB_CRC_MODE_32_IEEE_LE</span><span class="p">,</span> <span class="mh">0xffffffff</span><span class="p">,</span> <span class="p">(</span><span class="n">tb_byte_t</span> <span class="k">const</span><span class="o">*</span><span class="p">)</span><span class="n">points</span><span class="p">,</span> <span class="n">count</span> <span class="o">*</span> <span class="k">sizeof</span><span class="p">(</span><span class="n">gb_point_t</span><span class="p">));</span>

        <span class="c1">// make color
</span>        <span class="n">gb_color_t</span> <span class="n">color</span><span class="p">;</span>
        <span class="n">color</span><span class="p">.</span><span class="n">r</span> <span class="o">=</span> <span class="p">(</span><span class="n">tb_byte_t</span><span class="p">)</span><span class="n">crc32</span><span class="p">;</span>
        <span class="n">color</span><span class="p">.</span><span class="n">g</span> <span class="o">=</span> <span class="p">(</span><span class="n">tb_byte_t</span><span class="p">)(</span><span class="n">crc32</span> <span class="o">&gt;&gt;</span> <span class="mi">8</span><span class="p">);</span>
        <span class="n">color</span><span class="p">.</span><span class="n">b</span> <span class="o">=</span> <span class="p">(</span><span class="n">tb_byte_t</span><span class="p">)(</span><span class="n">crc32</span> <span class="o">&gt;&gt;</span> <span class="mi">16</span><span class="p">);</span>
        <span class="n">color</span><span class="p">.</span><span class="n">a</span> <span class="o">=</span> <span class="mi">128</span><span class="p">;</span>

        <span class="c1">// enable blend
</span>        <span class="n">gb_glEnable</span><span class="p">(</span><span class="n">GB_GL_BLEND</span><span class="p">);</span>
        <span class="n">gb_glBlendFunc</span><span class="p">(</span><span class="n">GB_GL_SRC_ALPHA</span><span class="p">,</span> <span class="n">GB_GL_ONE_MINUS_SRC_ALPHA</span><span class="p">);</span>

        <span class="c1">// apply color
</span>        <span class="k">if</span> <span class="p">(</span><span class="n">device</span><span class="o">-&gt;</span><span class="n">version</span> <span class="o">&gt;=</span> <span class="mh">0x20</span><span class="p">)</span> <span class="n">gb_glVertexAttrib4f</span><span class="p">(</span><span class="n">gb_gl_program_location</span><span class="p">(</span><span class="n">device</span><span class="o">-&gt;</span><span class="n">program</span><span class="p">,</span> <span class="n">GB_GL_PROGRAM_LOCATION_COLORS</span><span class="p">),</span> <span class="p">(</span><span class="n">gb_GLfloat_t</span><span class="p">)</span><span class="n">color</span><span class="p">.</span><span class="n">r</span> <span class="o">/</span> <span class="mh">0xff</span><span class="p">,</span> <span class="p">(</span><span class="n">gb_GLfloat_t</span><span class="p">)</span><span class="n">color</span><span class="p">.</span><span class="n">g</span> <span class="o">/</span> <span class="mh">0xff</span><span class="p">,</span> <span class="p">(</span><span class="n">gb_GLfloat_t</span><span class="p">)</span><span class="n">color</span><span class="p">.</span><span class="n">b</span> <span class="o">/</span> <span class="mh">0xff</span><span class="p">,</span> <span class="p">(</span><span class="n">gb_GLfloat_t</span><span class="p">)</span><span class="n">color</span><span class="p">.</span><span class="n">a</span> <span class="o">/</span> <span class="mh">0xff</span><span class="p">);</span>
        <span class="k">else</span> <span class="n">gb_glColor4f</span><span class="p">((</span><span class="n">gb_GLfloat_t</span><span class="p">)</span><span class="n">color</span><span class="p">.</span><span class="n">r</span> <span class="o">/</span> <span class="mh">0xff</span><span class="p">,</span> <span class="p">(</span><span class="n">gb_GLfloat_t</span><span class="p">)</span><span class="n">color</span><span class="p">.</span><span class="n">g</span> <span class="o">/</span> <span class="mh">0xff</span><span class="p">,</span> <span class="p">(</span><span class="n">gb_GLfloat_t</span><span class="p">)</span><span class="n">color</span><span class="p">.</span><span class="n">b</span> <span class="o">/</span> <span class="mh">0xff</span><span class="p">,</span> <span class="p">(</span><span class="n">gb_GLfloat_t</span><span class="p">)</span><span class="n">color</span><span class="p">.</span><span class="n">a</span> <span class="o">/</span> <span class="mh">0xff</span><span class="p">);</span>

        <span class="c1">// draw the edges of the filled contour
</span>        <span class="n">gb_glDrawArrays</span><span class="p">(</span><span class="n">GB_GL_TRIANGLE_FAN</span><span class="p">,</span> <span class="mi">0</span><span class="p">,</span> <span class="p">(</span><span class="n">gb_GLint_t</span><span class="p">)</span><span class="n">count</span><span class="p">);</span>

        <span class="c1">// disable blend
</span>        <span class="n">gb_glEnable</span><span class="p">(</span><span class="n">GB_GL_BLEND</span><span class="p">);</span>
<span class="cp">#endif
</span>    <span class="p">}</span>
    <span class="k">static</span> <span class="n">tb_void_t</span> <span class="nf">gb_gl_render_fill_polygon</span><span class="p">(</span><span class="n">gb_gl_device_ref_t</span> <span class="n">device</span><span class="p">,</span> <span class="n">gb_polygon_ref_t</span> <span class="n">polygon</span><span class="p">,</span> <span class="n">gb_rect_ref_t</span> <span class="n">bounds</span><span class="p">,</span> <span class="n">tb_size_t</span> <span class="n">rule</span><span class="p">)</span>
    <span class="p">{</span>
        <span class="c1">// check
</span>        <span class="n">tb_assert</span><span class="p">(</span><span class="n">device</span> <span class="o">&amp;&amp;</span> <span class="n">device</span><span class="o">-&gt;</span><span class="n">tessellator</span><span class="p">);</span>

<span class="cp">#ifdef GB_GL_TESSELLATOR_TEST_ENABLE
</span>        <span class="c1">// set mode
</span>        <span class="n">gb_tessellator_mode_set</span><span class="p">(</span><span class="n">device</span><span class="o">-&gt;</span><span class="n">tessellator</span><span class="p">,</span> <span class="n">GB_TESSELLATOR_MODE_TRIANGULATION</span><span class="p">);</span>
<span class="c1">//      gb_tessellator_mode_set(device-&gt;tessellator, GB_TESSELLATOR_MODE_MONOTONE);
</span><span class="cp">#endif
</span>
        <span class="c1">// set rule
</span>        <span class="n">gb_tessellator_rule_set</span><span class="p">(</span><span class="n">device</span><span class="o">-&gt;</span><span class="n">tessellator</span><span class="p">,</span> <span class="n">rule</span><span class="p">);</span>

        <span class="c1">// set func
</span>        <span class="n">gb_tessellator_func_set</span><span class="p">(</span><span class="n">device</span><span class="o">-&gt;</span><span class="n">tessellator</span><span class="p">,</span> <span class="n">gb_gl_render_fill_convex</span><span class="p">,</span> <span class="n">device</span><span class="p">);</span>

        <span class="c1">// done tessellator
</span>        <span class="n">gb_tessellator_done</span><span class="p">(</span><span class="n">device</span><span class="o">-&gt;</span><span class="n">tessellator</span><span class="p">,</span> <span class="n">polygon</span><span class="p">,</span> <span class="n">bounds</span><span class="p">);</span>
    <span class="p">}</span>
</code></pre>
</div>


        </article>
        <hr>

        <!-- baidu ads -->
        

        
        
            
        
            
            
                
            
        
            
        
            
            
                
            
        
            
        
            
            
                
            
        
            
        
            
            
                
            
        
            
        
            
            
                
            
        
            
        
            
            
                
            
        
            
        
            
            
                
            
        
            
        
            
            
                
            
        
            
        
            
            
                
            
        
            
            
                
            
        
            
        
            
            
                
            
        
            
        
            
            
                
            
        
            
        
            
            
                
            
        
            
        
            
            
                
            
        
            
            
                
            
        
            
            
                
            
        
            
        
            
            
                
            
        
            
        
            
            
                
            
        
            
        
            
        
            
            
                
            
        
            
            
                
            
        
            
        
            
            
                
            
        
            
            
                
            
        
            
        
            
            
                
            
        
            
        
            
            
                
            
        
            
            
                
            
        
            
            
                
            
        
            
        
            
            
                
            
        
            
        
            
            
                
            
        
            
        
            
            
                
            
        
            
        
            
            
                
            
        
            
            
                
            
        
            
        
            
            
                
            
        
            
            
                
            
        
            
        
            
            
                
            
        
            
        
            
            
                
            
        
            
        
            
            
                
            
        
            
            
                
            
        
            
        
            
            
                
            
        
            
            
                
            
        
            
            
                
            
        
            
            
                
            
        
            
            
                
            
        
            
            
                
            
        
            
        
            
            
                
            
        
            
        
            
            
                
            
        
            
        
            
            
                
            
        
            
        
            
            
                
            
        
            
        
            
            
                
            
        
            
        
            
            
                
            
        
            
        
            
            
                
            
        
            
        
            
            
                
            
        
            
        
            
            
                
            
        
            
        
            
            
                
            
        
            
        
            
            
                
            
        
            
        
            
            
                
            
        
            
        
            
            
                
            
        
            
        
            
            
                
            
        
            
        
            
            
                
            
        
            
        
            
            
                
            
        
            
        
            
            
                
            
        
            
            
                
            
        
            
        
            
            
                
            
        
            
        
            
            
                
            
        
            
        
            
            
                
            
        
            
        
            
            
                
            
        
            
            
                
            
        
            
            
                
            
        
            
        
            
            
                
            
        
            
            
                
            
        
            
            
                
            
        
            
        
            
            
                
            
        
            
            
                
            
        
            
        
            
            
                
            
        
            
        
            
            
                
            
        
            
        
            
            
                
            
        
            
        
            
            
                
            
        
            
        
            
            
                
            
        
            
            
                
            
        
            
            
                
            
        
            
        
            
            
                
            
        
            
            
                
            
        
            
        
            
            
                
            
        
            
            
                
            
        
            
        
            
            
                
            
        
            
            
                
            
        
            
        
            
            
                
            
        
            
        
            
            
                
            
        
            
            
                
            
        
            
        
            
            
                
            
        
            
            
                
            
        
            
        
            
            
                
            
        
            
        
            
            
                
            
        
            
        
            
            
                
            
        
            
        
            
            
                
            
        
            
            
                
            
        
            
        
            
            
                
            
        
            
        
            
            
                
            
        
            
            
                
            
        
            
            
                
            
        
            
        
            
            
                
            
        
            
            
                
            
        
            
        
            
            
                
            
        
            
            
                
            
        
            
        
            
            
                
            
        
            
            
                
            
        
            
            
                
            
        
            
            
                
            
        
            
        
            
            
                
            
        
            
        
            
            
                
            
        
            
        
            
            
                
            
        
            
            
                
            
        
            
        
            
            
                
            
        
            
            
                
            
        
            
            
                
            
        
            
            
                
            
        
            
        
            
            
                
            
        
            
            
                
            
        
            
        
            
            
                
            
        
            
        
            
            
                
            
        
            
        
            
            
                
            
        
            
            
                
            
        
            
            
                
            
        
            
        
            
            
                
            
        
            
            
                
            
        
            
            
                
            
        
            
            
                
            
        
            
            
                
            
        
            
            
                
            
        
            
            
                
            
        
            
            
                
            
        
            
            
                
            
        
            
            
                
            
        
            
            
                
            
        
            
            
                
            
        
            
            
                
            
        
            
            
                
            
        
            
            
                
            
        
            
            
                
            
        
            
            
                
            
        
            
            
                
            
        
            
            
                
            
        
            
            
                
            
        
            
            
                
            
        
            
            
                
            
        
            
            
                
            
        
            
            
                
            
        
            
            
                
            
        
            
        
            
            
                
            
        
            
        
            
            
                
            
        
            
            
                
            
        
            
            
                
            
        
            
            
                
            
        
            
        
            
            
                
            
        
            
        
            
            
                
                    
                    <h2 id="chinese">中文</h2>
                    <ul>
                    
                    <li class="relatedPost">
                        <a href="/cn/2016/07/21/tessellate-polygon-algorithm/">复杂多边形光栅化算法
                        
                        </a>
                    </li>
                    
                    
                
            
        
            
        
            
        
            
            
                
            
        
            
            
                
            
        
            
        
            
            
                
            
        
            
            
                
            
        
            
        
            
            
                
            
        
            
        
            
            
                
            
        
            
            
                
            
        
            
        
            
            
                
            
        
            
        
            
            
                
            
        
            
            
                
            
        
            
        
            
            
                
            
        
            
            
                
            
        
            
        
            
            
                
            
        
            
        
            
            
                
            
        
            
        
            
        
            
        
            
        
            
        
            
            
                
            
        
            
        
            
            
                
            
        
            
            
                
            
        
            
            
                
            
        
            
            
                
            
        
            
            
                
            
        
            
            
                
            
        
            
            
                
            
        
            
            
                
            
        
            
            
                
            
        
            
        
            
            
                
            
        
            
        
            
            
                
            
        
            
            
                
            
        
            
            
                
            
        
            
            
                
            
        
            
            
                
            
        
            
            
                
            
        
            
            
                
            
        
            
            
                
            
        
            
            
                
            
        
            
            
                
            
        
            
            
                
            
        
            
            
                
            
        
            
            
                
            
        
            
            
                
            
        
            
            
                
            
        
            
        
            
            
                
            
        
            
        
            
            
                
            
        
            
        
            
            
                
            
        
            
        
            
            
                
            
        
        
            </ul>
        

        
        
            
            
            
                
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                
            
                
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                
            
                
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                
            
                
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                
            
                
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                
            
            
        
            
        
            
            
            
                
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                
            
                
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                
            
                
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                
            
                
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                
            
                
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                
            
                
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                
            
                
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                
            
            
        
            
        
            
            
            
                
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                
            
                
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                
            
                
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                
            
                
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                
            
                
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                
            
                
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                
            
                
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                
            
                
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                
            
                
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                
            
                
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                
            
                
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                
            
                
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                
            
            
        
            
        
            
            
            
                
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                
            
                
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                
            
                
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                
            
                
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                
            
                
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                
            
                
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                
            
            
        
            
        
            
            
            
                
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                
            
                
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                
            
                
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                
            
                
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                
            
                
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                
            
                
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                
            
            
        
            
        
        

        <div class="post-recent">
    <div class="pre">

        

        

        
        
        

        

        

        
        
        <p><strong>Prev Post</strong> <a href="/2016/07/19/how-to-install-xmake/">How to install xmake</a></p>
        
    </div>

    <div class="nex">

        

        

        
        
        

        

        

        
        
        <p><strong>Next Post</strong> <a href="/2016/07/22/how-to-compile-on-cross-toolchains/">How to complie project using the cross-toolchains</a></p>
        
    </div>
</div>


        <h2 id="comments">Comments</h2>
        






<div id="gitalk-container"></div>
<link rel="stylesheet" href="/css/gitalk.css">
<script src="/js/gitalk.min.js"></script>

<script>
const gitalk = new Gitalk({
  clientID: '73946dc1d9e2276ad0da',
  clientSecret: '12a3cb94361ba3ebc6ecb68cf80d592bfaa8106d',
  repo: 'tboox.github.io',
  owner: 'waruqi',
  admin: ['waruqi'],
  id: location.pathname,      
  language: 'en',
  distractionFreeMode: false  
})

gitalk.render('gitalk-container')
</script>





    </div>
    <button class="anchor"><i class="fa fa-anchor"></i></button>
    <div class="right">
        <div class="wrap">


            <!-- codefund ads -->
            

            <!-- Content -->
            <div class="side content">
                <div>
                    Content
                </div>
                <ul id="content-side" class="content-ul">
                    <li><a href="#chinese">中文</a></li>
                    <li><a href="#similar_posts">Similar Posts</a></li>
                    <li><a href="#comments">Comments</a></li>
                </ul>
            </div>

            <!-- baidu ads -->
            

            <br>
            <div class="side">
                <div>
                    <i class="fa fa-external-link"></i>
                    Links
                </div>
                <ul class="content-ul">
                  <li><a href="http://github.com/waruqi/tbox">tbox</a></li>
                  <li><a href="http://www.xmake.io">xmake</a></li>
                  <li><a href="https://github.com/waruqi">github</a></li>
                </ul>
            </div> 

            <!-- google ads -->
            

            <!-- baidu ads -->
            

            <!-- chitika ads -->
            
        </div>
    </div>

    <!-- baidu ads -->
    
</div>
<script>
/**
 * target _blank
 */
(function() {
    var aTags = document.querySelectorAll('article a:not([id])')
    for (var i = 0; i < aTags.length; i++) {
        aTags[i].setAttribute('target', '_blank')
    }
}());
</script>
<script src="/js/pageContent.js " charset="utf-8"></script>



    <footer class="site-footer">
    <div class="wrapper">
        <p class="description">
             Copyright (c) 2016-2020 tboox.org 
        </p>
        <p class="contact">
            
            <a href="https://github.com/waruqi" title="GitHub"><i class="fa fa-github" aria-hidden="true"></i></a> 
             
            
            <a href="mailto:waruqi@gmail.com" title="email"><i class="fa fa-envelope-o" aria-hidden="true"></i></a> 
            
            
            <a href="https://twitter.com/waruqi" title="Twitter"><i class="fa fa-twitter" aria-hidden="true"></i></a> 
            
            <a href="/feed.xml" title="feed"><i class="fa fa-feed" aria-hidden="true"></i></a> 
        </p>
        <p class="power">
            <span>
                Site powered by <a href="https://jekyllrb.com/">Jekyll</a> & <a href="https://github.com/Gaohaoyang">HyG</a> & <a href="https://pages.github.com/">Github Pages</a>.
            </span>
        </p>
    </div>
</footer>

    <div class="back-to-top">
    <a href="#top" class="scroll">
        <i class="fa fa-arrow-up" aria-hidden="true"></i>
    </a>
</div>

    <script src=" /js/main.js " charset="utf-8"></script>
    <script src=" /js/scroll.min.js " charset="utf-8"></script>
  </body>

</html>
